Skip to content

Affiliate ready state with leader election with a flag ha-enable-leader-election #1337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

yangligt2
Copy link

Closes #1264

Summary

This PR introduces a leader election mechanism using Kubernetes Leases to allow the service to run in a high-availability (HA) mode. When enabled, only the leader instance will run the main reconciliation loop, preventing multiple replicas from acting on the same resources simultaneously.

Implementation Details

  • Leverages the controller-runtime manager's built-in leader election functionality.
  • A new boolean flag, --ha-enable-leader-election, is added to enable/disable this feature. It is false by default to maintain backward compatibility.
  • The deployment manifest has been updated to include the necessary RBAC permissions for the service account to get, create, update, and patch leases in the coordination.k8s.io API group.

How to Test

Added 2 new test cases in test-e2e to:

  1. validate that leader is with state READY 1/1
  2. Delete the leader, wait for an existing pod to become the new leader, and run all existing e2e test again.

To run the test, use command E2E_LEADER_ELECTION_ENABLED=true make test-e2e

Copy link

linux-foundation-easycla bot commented Aug 8, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

netlify bot commented Aug 8, 2025

Deploy Preview for gateway-api-inference-extension ready!

Name Link
🔨 Latest commit 6d01b66
🔍 Latest deploy log https://app.netlify.com/projects/gateway-api-inference-extension/deploys/6896880649c004000896cfb2
😎 Deploy Preview https://deploy-preview-1337--gateway-api-inference-extension.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Aug 8, 2025
@k8s-ci-robot
Copy link
Contributor

Welcome @yangligt2!

It looks like this is your first PR to kubernetes-sigs/gateway-api-inference-extension 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/gateway-api-inference-extension has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 8, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @yangligt2. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 8, 2025
@kfswain
Copy link
Collaborator

kfswain commented Aug 8, 2025

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 8, 2025
@kfswain
Copy link
Collaborator

kfswain commented Aug 8, 2025

/lgtm
/approve

Comitted a small typo edit, but otherwise looks great! Thank you for this!

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 8, 2025
@kfswain
Copy link
Collaborator

kfswain commented Aug 8, 2025

/hold

Ahh shoot. Can we add the flag to the helm chart?

This file here:

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 8, 2025
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 8, 2025
@kfswain
Copy link
Collaborator

kfswain commented Aug 8, 2025

/lgtm
/approve

Thanks!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 8, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kfswain, yangligt2

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@nirrozenbaum
Copy link
Contributor

/hold

Ahh shoot. Can we add the flag to the helm chart?

This file here:

and to the chart README please.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2025
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@kfswain
Copy link
Collaborator

kfswain commented Aug 10, 2025

forgot to unhold, sorry about that!

since we need to rebase anyway, updating the readme would be great.
/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 10, 2025
@k8s-ci-robot
Copy link
Contributor

@yangligt2: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-gateway-api-inference-extension-test-unit-main 6d01b66 link unknown /test pull-gateway-api-inference-extension-test-unit-main
pull-gateway-api-inference-extension-test-e2e-main 6d01b66 link unknown /test pull-gateway-api-inference-extension-test-e2e-main
pull-gateway-api-inference-extension-verify-main 6d01b66 link unknown /test pull-gateway-api-inference-extension-verify-main

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optionally allow Ready Status to be affiliated with Leader Election
4 participants